const express = require('express')
// 处理api的请求
// 创建一个 Router
const router = express.Router()
const stuServ = require("../../services/studentService")
router.get("/", async (req,res)=>{
    const page = req.query.page || 1;
    const limit = req.query.limit || 10;
    const sex = req.query.sex || -1;
    const name = req.query.name || "";
    stuServ.getStudents(page, limit, sex, name)
    console.log("分页获取 student")
    res.send("分页获取 student")
})
router.get("/:id", (req,res)=>{
    console.log("获取 对应 id student")
    res.send("获取 对应 id student")
})
router.post("/", (req,res)=>{
    console.log("添加 student")
    res.send("添加 student")
})
router.delete("/:id", (req,res)=>{
    console.log("删除对应 student")
    res.send("删除对应 student")
})
router.put("/:id", (req,res)=>{
    console.log("修改对应 student")
    res.send("修改对应 student")
})


// app.post('/api/student', (req, res) => {
//     // 添加 student
// })
// app.get('/api/student', (req, res) => {
//     // 获取 student
// })
// app.put('/api/student/:id', (req, res) => {
//     // 修改 student
// })
module.exports = router;